package com.bianmin.Controller;

import com.bianmin.Data.Result;
import com.bianmin.Mapper.OrderMapper;
import com.bianmin.Model.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("api/order")
public class OrderController {

    @Autowired
    private OrderMapper orderMapper;

    //订单列表
    @PostMapping("list")
    public Result<Object> orderList(@RequestBody Map<String,Object> map) {
        String userId = map.get("userId").toString();
        Integer page = Integer.parseInt(map.get("page").toString());
        Integer pageSize = Integer.parseInt(map.get("pageSize").toString());
        List<Order> orders = orderMapper.orderList(userId, page * pageSize, pageSize);
        return Result.success(orders);
    }

}
